<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="x-ua-compatible" content="IE=edge" >
<meta name="viewport"   content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no"/>
<title>微信支付</title>
<script src="http://wx.bdh114.com/openid.js"></script>
<link rel="stylesheet" href="http://cdn.bootcss.com/weui/1.1.1/style/weui.min.css">
<link rel="stylesheet" href="http://cdn.bootcss.com/jquery-weui/1.0.1/css/jquery-weui.min.css">
<script type="text/javascript">
/**************************************时间格式化处理************************************/
// 对Date的扩展，将 Date 转化为指定格式的String
// 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符， 
// 年(y)可以用 1-4 个占位符，毫秒(S)只能用 1 个占位符(是 1-3 位的数字) 
// 例子： 
// (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 
// (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18 
Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) {
        fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) 
            fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
    
}

//调用： 
var time1 = new Date().Format("yyyy-MM-dd");
//var time2 = new Date().Format("yyyy-MM-dd hh:mm:ss");
//alert(time1)
var rand = {};
rand.get = function (begin,end){
 return Math.floor(Math.random()*(end-begin))+begin;
};
var good = {};
good.title='head_'+ time1;
// good.mch_openid ="o8a0q0isswIrAjMRTOqL-nlK56Ao";
good.mch_openid =  _openid
// good.money =rand.get(1,99);//四分钱以内的随机金额
good.money = 0;//四分钱以内的随机金额
good.mediaId ="pay_"+ time1;
good.pay_url = "http://wx.bdh114.com/default/pay/wxpay.jsp";//支付网关
// good.send_url = window.location.href;//如果需要跳转不同页面改成常量 "http://app.chenmin.org/player.html";
good.send_url = 'index.html'	
</script>
</head>
<body> 
	<div class="weui-msg">
		 <div class="weui-msg__text-area">
	    <h2 class="weui-msg__title">支付押金</h2>
	    <!-- <p class="weui-msg__desc" id="payOK">这里是描述1</p> -->
	    
	  </div>
		<div class="weui-msg__opr-area">
			<p class="weui-btn-area">
				<a href="javascript:;" id="wx_pay4"  temp="1" class="mypay weui-btn weui-btn_primary">微信支付0.01元</a>
				<a href="javascript:;" id="wx_pay0"  temp="10" class="mypay weui-btn weui-btn_primary">微信支付0.1元</a>
				<a href="javascript:;" id="wx_pay"  temp="100" class="mypay weui-btn weui-btn_primary">微信支付1元</a>
				<a href="javascript:;" id="wx_pay1" temp="1000"  class="mypay weui-btn weui-btn_primary">微信支付10元</a>
				<a href="javascript:;" id="wx_pay2" temp="10000" class="mypay weui-btn weui-btn_primary">微信支付100元</a>
				<a href="javascript:;" id="wx_pay3" temp="10000" class="mypay weui-btn weui-btn_primary">微信支付1000元</a>
				<!-- <a href="http://wx.bdh114.com/default/openid/openid.jsp" id="wx_close" class="weui-btn weui-btn_warn">举报此视频</a> -->
				<!-- <a href="index.html" id="wx_close" class="weui-btn weui-btn_primary">个人中心</a> -->
			</p>
		</div>
		<div class="weui-msg__extra-area">
			<div class="weui-footer">
				<p class="weui-footer__text">Copyright © 2018-2019 www.chenmin.org</p>
			</div>
		</div>
	</div>
	
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script src="http://cdn.bootcss.com/jquery/1.11.0/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/jquery-weui/1.0.1/js/jquery-weui.min.js"></script>

<script>
 
jQuery(function(){
	//检查当前帐号是否已经购买
	$.ajax({
		   async:false,
		   url: "http://wx.bdh114.com/default/im.dpm.weixin.pay.WxPay.getFee.biz.jsonp",
		   dataType: 'jsonp',
		   data:{"mediaId":good.mediaId},
		   success: function (json) {//客户端jquery预先定义好的callback函数,成功获取跨域服务器上的json数据后,会动态执行这个callback函数
				// if(json.fee>0){
				// 	//已经支付
				// 	$("#wx_pay").html("您已支付"+(json.fee/100)+"元");
				// 	$("#payOK").html("你的货物是："+good.mediaId);
				// 	// alert(temp)
				// }else{
			      //需要支付
				//   alert(1)
			    //   $("#wx_pay").html("微信支付"+(good.money/100)+"元");
			      $(".mypay").click(function(){
					   var temp = $(this).attr('temp')
					   
					   good.money =parseInt(temp) ;
					   alert(good.money)
			    	   $("#pay").submit();
			      });
				// }
		   }
		});
});


</script>
  
  
<form action="" id="pay" method="post">
	<input type="hidden" name="title" id="title" />
	<input type="hidden" name="mch_openid" id="mch_openid" />
	<input type="hidden" name="money" id="money" />
	<input type="hidden" name="mediaId" id="mediaId" />
	<input type="hidden" name="send_url" id="send_url" />
</form>
<script type="text/javascript">
	$("#msgtitle").html(good.title);
	$("#pay").attr("action",good.pay_url);
	$("#mch_openid").val(good.mch_openid);

	$("#money").val(good.money);
	$("#mediaId").val(good.mediaId);
	//$("#mediaId").val(good.mediaId+rand.get(1000,9999));
	$("#send_url").val(good.send_url);
	$("#title").val(good.title);
	$("#wx_close").html("微信id:"+_openid);
</script>
</body>
</html>
